import { defHttp } from '/@/utils/http/axios';
import { GetPermissionListResponseModel, PermissionModel } from './model/permissionModel';

// 定义请求地址的枚举
enum Api {
  GetPermissionList = '/admin/acl/permission',
  RemovePermission = '/admin/acl/permission/remove',
  SavePermission = '/admin/acl/permission/save',
  UpdatePermission = '/admin/acl/permission/update',
}

export const getPermissionListApi = () => {
  return defHttp.get<GetPermissionListResponseModel>({
    url: Api.GetPermissionList,
  });
};

export const removePermissionApi = (id: string) => {
  return defHttp.delete<null>({
    url: Api.RemovePermission,
    params: `/${id}`,
  });
};

export const savePermissionApi = (permission: PermissionModel) => {
  return defHttp.post<null>({
    url: Api.SavePermission,
    data: permission,
  });
};

export const updatePermissionApi = (permission: PermissionModel) => {
  return defHttp.put<null>({
    url: Api.UpdatePermission,
    data: permission,
  });
};
